
local data = load_excel('存档数据.xlsx','存档挑战')
local list = {}
for _,da in ipairs(data) do
    local name = da['名称']
    da.tip = da['效果']
    ac.lni('item',name,da)
    table.insert(list,name)
end


ac.item('个人挑战'){
    empty_item = true,
    on_sell = function(self,hero,player)
        local point = player.cd_point
        player:notify('玩家-传送',player,point)
    end
}

ac.item('团队试炼'){
    empty_item = true,
    model1 = [[Abilities\Spells\Human\MassTeleport\MassTeleportTo.mdl]],
    model2 = [[Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl]],
    on_sell = function(self,hero,player)
        if self.open then
            return
        end
        self.open = true
        local time = 5
        ac.each_player(function(player)
            local hero = player.hero
            if hero then
                hero:add_effect(self.model1,'origin',5)
            end
        end)
        ac.loop(1000,function(t)
            if time<=0 then
                t:remove()
                ac.game:notify('开启团队试炼')
                ac.each_player(function(player)
                    local hero = player.hero
                    if hero then
                        hero:add_effect(self.model2):remove()
                    end
                end)
                return
            end
            ac.player.self:send_msg(('|cffffff00团队试炼倒计时:|r|cff00ff00%s|r'):format(time))
            time = time - 1
        end):on_timer()
    end
}



local rect = ac.rect.j_rect('base')
local point = rect:get_point()
ac.game:event '游戏-游戏胜利'(function()
    ac.game:notify('游戏-删除商店')
    ac.game:fogmask(false)
    
    local unit = ac.player[5]:create_unit('存档挑战',point,270)
    for _, name in ipairs(list) do
        unit:add_sell(name)
    end
end)
